package net.simflow.swf.analyzer.network.stats.opt;

import java.util.HashSet;

import net.simflow.swf.analyzer.network.data.Link;
import net.simflow.swf.analyzer.network.data.Network;
import net.simflow.swf.analyzer.network.data.Node;

public class NetworkLinkSetAnalyzer {

	private static NetworkLinkSetAnalyzer instance = new NetworkLinkSetAnalyzer();

	private NetworkLinkSetAnalyzer() {
	}

	public static NetworkLinkSetAnalyzer getInstance() {
		return instance;
	}

	public HashSet<Link> analyze(Network network) {
		if (network == null) {
			return null;
		}

		HashSet<Link> set = new HashSet<Link>();
		for (Node pn : network.getNodeSet()) {
			for (Node cn : pn.getChildDataSet()) {
				set.add(new Link(pn, cn, false));
			}
			for (Node cn : pn.getChildControlSet()) {
				set.add(new Link(pn, cn, true));
			}
		}

		return set;
	}
}
